<?php
	session_start();
	include("../../include/dbconnect.php");
	extract($_POST);
	$table="quyengroups";
	$strdk=" where $table.magrp='$magrp' and $table.mamod='$mamod'";
	
	$SQL="select * from modules where ma='$mamod'";
	$result=mysql_query($SQL,$conn) or die($SQL);
	$a=mysql_fetch_array($result);
	$tenmod=$a['ten'];
	mysql_free_result($result);
	
	header("Content-Type: text/xml");
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
	echo "<quyengroups>";
	if($_SESSION["un"]=="")
	{
		echo "<status>fail</status>";
		echo "<count>0</count>";
		echo "<message>Chưa đăng nhập !</message>";
	}
	else 
	{
		$SQL="SELECT $table.*,modules.ten as tenmod FROM ";
			$SQL=$SQL."($table inner join modules on ($table.mamod=modules.ma)) ";
			$SQL = $SQL."$strdk";  
			$result=mysql_query($SQL,$conn) or die($SQL);
			echo "<status>ok</status>";
			echo "<count>",mysql_num_rows($result),"</count>";
			echo "<message>OK</message>";	
			if($a=mysql_fetch_array($result))
			{
				echo "<row id='",$a["id"],"'>";
				echo "<cell>",$a["id"],"</cell>"; //0
				echo "<cell>",$a["mamod"],"</cell>"; //1
				echo "<cell>",$a["select_r"],"</cell>"; //2
				echo "<cell>",$a["insert_r"],"</cell>"; //3
				echo "<cell>",$a["update_r"],"</cell>"; //4
				echo "<cell>",$a["delete_r"],"</cell>"; //5
				echo "<cell>",$a["mamod"],"</cell>"; //6
				echo "</row>";
			}
			else
			{
				echo "<row id='",$magrp.$mamod,"'>";
				echo "<cell>",$magrp.$mamod,"</cell>"; //0
				echo "<cell>",$mamod,"</cell>"; //1
				echo "<cell>K</cell>"; //2
				echo "<cell>K</cell>"; //3
				echo "<cell>K</cell>"; //4
				echo "<cell>K</cell>"; //5
				echo "<cell>",$mamod,"</cell>"; //6
				echo "</row>";
			}
			mysql_free_result($result);
	}

	echo "</quyengroups>";
	include("../../include/dbclose.php");
?>